﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace Biuro.Formy
{
    public partial class AddEditTransport : Form
    {
        public string Nazwa
        {
            get { return tbNazwa.Text; }
            set { tbNazwa.Text = value; }
        }
        public string Przewoznik
        {
            get { return tbPrzewoznik.Text; }
            set { tbPrzewoznik.Text = value; }
        }
        public string Opis
        {
            get { return tbOpis.Text; }
            set { tbOpis.Text = value; }
        }
        public AddEditTransport()
        {
            InitializeComponent();
        }

        private void btDodaj_Click(object sender, EventArgs e)
        {
            if (!Regex.IsMatch(tbNazwa.Text.ToLower(), @"\b\p{L}{2,25}\b"))
            {
                tbNazwa.BackColor = Color.Red;
            }
            else
            {
                tbNazwa.BackColor = Color.White;
                this.DialogResult = DialogResult.OK;
            }
        }
        public void Reset()
        {
            foreach (TextBox t in this.Controls.OfType<TextBox>().ToArray())
                t.Text = "";
        }
        //on load
        private void reset(object sender, EventArgs e)
        {
            Reset();
        }

        private void AddEditTransport_Paint(object sender, PaintEventArgs e)
        {
            System.Drawing.Drawing2D.LinearGradientBrush basebackground;
            basebackground = new System.Drawing.Drawing2D.LinearGradientBrush(new Point(0, 0), new Point(0, ClientSize.Height), Color.White, Color.LightGray);
            e.Graphics.FillRectangle(basebackground, ClientRectangle);
        }
    }
}
